﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DSheet.Core;
using DSheet.Core.Data;

namespace DExcelServiceApp
{
    public partial class DocDefPreview : System.Web.UI.Page
    {
        private Guid DocDefId { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DocDefId = new Guid(this.Request.QueryString["docid"]);
                _ctlHiddenDocDefId.Value = DocDefId.ToString();
                DocDef docDef = null;
                List<DRow> yRows = null;
                List<DRow> xRows = null;


                using (DBContext context = new DBContext())
                {
                    docDef = DocDefService.GetDocDef(context, DocDefId);
                    DContext dContext = new DContext();
                    dContext.DBContext = context;
                    yRows = docDef.YDims.CalcDTree(dContext).Complanate();
                    xRows = docDef.XDims.CalcDTree(dContext).Complanate();
                }

                _ctlListYDim.DataSource = yRows;
                _ctlListYDim.DataBind();
                _ctlListXDim.DataSource = xRows;
                _ctlListXDim.DataBind();
            }
            else
            {
                DocDefId = new Guid(_ctlHiddenDocDefId.Value);
            }
        }

        protected void _ctlBtnPublish_Click(object sender, EventArgs e)
        {
        }
    }
}